package com.liu.lab04.listener;

import jakarta.servlet.ServletContextListener;
import jakarta.servlet.http.HttpSessionAttributeListener;
import jakarta.servlet.http.HttpSessionBindingEvent;

import java.util.Date;

public class AccountListener  implements HttpSessionAttributeListener {
    public void attributeAdded(HttpSessionBindingEvent event) {
        if(event.getName().equals("user")){
            System.out.println("日志消息：[用户--"+(new Date())+"]" + event.getValue() +"登录");
        }
    }
    public void attributeRemoved(HttpSessionBindingEvent event) {
        if(event.getName().equals("user")){
            System.out.println("日志消息：[用户--"+(new Date())+"]" + event.getValue() +"注销");
        }
    }
    public void attributeReplaced(HttpSessionBindingEvent event) {

    }
}
